package com.lee.mysql.vo;

public class Result<T> {

    /** 表示成功 */
    public final static String SUCCESS="0";

    /** 操作失败 */
    public final static String FAIL="1";



    private String errorCode="0";

    private String desc="";

    private T data;

    public Result(){}

    public Result(String errorCode,String desc,T data){
        this.errorCode=errorCode;
        this.desc=desc;
        this.data=data;
    }

    public Result(String errorCode,String desc){
        this.errorCode=errorCode;
        this.desc=desc;
    }

    public Result(String errorCode,T data){
        this.errorCode=errorCode;
        this.data=data;
    }

    public  static Result<String> ofSuccess(){
        return new Result<>(SUCCESS,"操作成功",null);
    }

    public  static Result<String> ofSuccess(String desc){
        return new Result<>(SUCCESS,desc,null);
    }

    public  static Result<String> ofSuccess(String desc,String data){
        return new Result<>(SUCCESS,desc,data);
    }

    public  static Result<String> ofFail(){
        return new Result<>(FAIL,"操作失败",null);
    }

    public  static Result<String> ofFail(String desc){
        return new Result<>(FAIL,desc,null);
    }

    public  static Result<String> ofFail(String desc,String data){
        return new Result<>(FAIL,desc,data);
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
